from app.libs.case_group_util.group_by_group import group_by_v
from app.libs.error_code import Success
from app.libs.mongo_about.run_count import get_count
from app.libs.mongo_about.get_day_error_log import get_day_error
from app.libs.mongo_about.get_log_top import get_success_log_top
from app.libs.redprint import Redprint
from app.libs.token_auth import login_required
from flask import g

from app.models.case_group import CaseGroupModel

api = Redprint('visual')


@api.route('/success_rate', methods=['GET'])
@login_required
def get_log_top():
    # 获取所多log并且讲成功率最高的前10 展示
    data = get_success_log_top()
    return Success(data=data)


@api.route('/day', methods=['GET'])
@login_required
def get_day_log():
    # 获取所多log并且讲成功率最高的前10 展示
    data = get_day_error()
    return Success(data=data)


@api.route('/group', methods=['GET'])
@login_required
def get_group_case():
    return Success(data=CaseGroupModel.get_ex_group())


@api.route('/run_case_count', methods=['GET'])
def get_run_case_count():
    return Success(data=get_count())
